package com.test0109;

public class Test02 {
    public static void main(String[] args) {
        // (2)统计字符串中某个字符串出现的次数
        String s = "lskdabcjfsaabcdkfhwerwerabc";
        int i = m(s, "abc");
        System.out.println(i);
    }
    public static int m(String str,String str1){
        int count= 0;
        int index = 0;
        while ((index = str.indexOf(str1,index))!=-1){//indexof 找不到就返回-1;
            count++;
            index +=str1.length();
        }
        return count;
    }

}
